<?php
class listAction extends security_normal {
	
	function action(){
		$CategoryFN=$this->_getParamId(1);
		$PageFN=$this->_getParamId(2);
		$htmlfn=MICE_DIR.'list/'.$CategoryFN.'/'.$PageFN;
		if(MICE_HTML){
				if(file_exists($htmlfn)){
				include_once $htmlfn;
				exit;
			}
		}
		$PageId=preg_replace("/(\w+)_(\d+)".MICE_HTML_EXT."/i","\${2}",$PageFN);
		if($PageId<1)	$PageId=1;
		
		if(is_numeric($PageId) AND $CategoryFN!=''){
			global $conn;
			$category=new model_Category();
			if(is_numeric($CategoryFN)){
				$category->setSubsection('WHERE type LIKE \'article%\' AND isvisible=0 AND (filename=\''.$CategoryFN.'\' OR category_id='.$CategoryFN.') ORDER BY path');
			}else{
				$category->setSubsection('WHERE type LIKE \'article%\' AND isvisible=0 AND filename=\''.$CategoryFN.'\' ORDER BY path');
			}
			$CategoryRS=$category->doSelectOne();
			$CategoryId=$CategoryRS->getCategoryId();

			if($CategoryRS){
				if($CategoryRS->getUrl()){
					//跳转
					echo '<html><body><form action="'.MiceRestoreQuote('micefun',$CategoryRS->getUrl()).'"  method="post" id="link" name="link"  target="_blank"  style="display:none;"></form><Script LANGUAGE="JavaScript">document.getElementById("link").submit();history.back(-1);</script></body></html>';
					exit;
				}
				if($CategoryRS->getTpl()){								//模板
					$tpl=$CategoryRS->getTpl();
				}else{
					$filename = new getTPLFileName(__CLASS__);
					$tpl=$filename->TPLFileName;
				}
			}else{
				MessageBox('错误信息',MICE_URL,'对不起,您查看的分类不存在或已经被删除');
				exit;
			}
		}else{
			MessageBox('参数错误',MICE_URL);
			exit;
		}
		$miceSession = new session();
		if($miceSession->get('mu__grouplevel')<$CategoryRS->getGroupId() and $CategoryRS->getGroupId()>0)	MessageBox('只有会员才能查看,您尚未登录或注册',MICE_URL.'index.php');

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign('CategoryRS',$CategoryRS);
		$smarty->assign('CategoryId',$CategoryId);
		$smarty->assign('PageId',$PageId);

		if(MICE_HTML){
			//将内容写入至静态文件
			$content = $smarty->fetch($tpl);
			$fp = fopen($htmlfn, 'w'); 
			fwrite($fp, $content); 
			fclose($fp);
		}

		$smarty->display($tpl);
	}	
}
?>